'use strict';

advertService.$inject = ['$http'];

function advertService($http) {

  return {
      getBystatus: getBystatus,
      updateStatus: updateStatus,
      getByNotstatus: getByNotstatus,
      getonordown: getonordown
  }

  function updateStatus(advert){
      $http.post("http://10.222.29.187:8999/m/foodAd/foodAdUpdateStatus",{food:advert.food,merchant:advert.merchant.icNum,status:advert.status});
      return $http.post("/a/advert/modify",advert);
  }

  function getBystatus(status) {
      return $http.get("/a/advert/get/"+ status);
  }

  function getByNotstatus(status) {
      return $http.get("/a/advert/getnot/"+ status);
  }

  function getonordown() {
      return $http.get("/a/advert/getonordown");
  }
}

module.exports = advertService;